const app = getApp()
import {
  HomeIndex
} from 'index-modal.js';
import {
  Config
} from '../../../utils/config.js';
var Function = require("../../../utils/function.js");
var index = new HomeIndex(); //实例化 首页 对象
Page({

  /**
   * 页面的初始数据
   */
  data: {
    relame:[],
    activeindex:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({id:options.id})
    this._cancel(1)
  },

  _cancel(type){
    let that = this;
    if(type == 1){
      index.cancel({},(res)=>{
        if(res.code == 200){that.setData({relame:res.data})}
      })
    }else{
      let data = {
        title: that.data.relame[that.data.activeindex].title,
        id: that.data.id
      }
      index.cancel(data,(res)=>{
        if(res.code == 200){
          wx.showToast({
            title: res.msg,
            duration:1000,
            icon:"none"
          })

          setTimeout(()=>{
            wx.navigateBack()
          },1000)
        }else{
          wx.showToast({
            title: res.msg,
            duration: 1000,
            icon: "none"
          })
        }
      })
    }
  },
  goyew(){
    this._cancel(2)
  },
  selcty(e){
    let idx = parseInt(e.currentTarget.dataset.index);
    if (idx == this.data.activeindex){return;}
    this.setData({ activeindex: idx})
  }

 
})